#ifndef REREQUESTOR_H
#define REREQUESTOR_H

#include <Injector/injector.h>
#include <Packet/packet.h>
#include <vector>
#include <utility>

class Rerequestor
{
public:
    Rerequestor();
    Rerequestor( const Rerequestor &r );
    void setNewSource( const uint32_t &ip );
    void setNewSourcePort( const uint16_t &port );
    void setNewDestination( const uint32_t &ip );
    void setNewDestinationPort( const uint16_t &port );
    void setDevice( const std::string &device );
    std::string device( ) const;
    uint32_t newSource() const;
    uint32_t newDestination() const;
    uint16_t newSourcePort() const;
    uint16_t newDestinationPort() const;
    void processPacket( const Packet &p );
    void setName( const std::string& name );
    std::string name() const;

private:
    void removeIPv4FromRepeatList( const uint32_t &ip );
    void addIPv4ToRepeatList( const uint32_t &ip );
    bool isInIPv4RepeatList( const uint32_t &ip);

private:
    Injector injector_;
    uint32_t newSource_;
    uint16_t newSourcePort_;
    uint32_t newDestination_;
    uint16_t newDestinationPort_;
    std::string name_;
    static std::vector< std::pair<uint32_t, int> > repeatDestinations_; //All the destinations for the dup packets. This is to avoid loops.
};

#endif // REREQUESTOR_H
